{% extends('layout.html') %}
{% block body %}
<section id="tabs-bar" class="tabsbar">
    <div class="container">
        <div class="row">
            <div class="col s12 m12 l12 xl12">
                <ul class="tabs">
                    <li class="tab col s3 m3 l4 xl2"><a {% if tab=='1' %} class="active" {% endif %} href="#categories"
                            onclick="activeTab(1)">Categories</a></li>
                    <li class="tab col s3 m3 l4 xl2"><a {% if tab=='2' %} class="active" {% endif %} href="#tlds"
                            onclick="activeTab(2)">TLDs</a></li>
                    <li class="tab col s3 m3 l4 xl2"><a {% if tab=='3' %} class="active" {% endif %} href="#keywords"
                            onclick="activeTab(3)">Keywords</a></li>
                </ul>
            </div>
        </div>
    </div>
</section>
<section id="categories" class="section">
    <div class="container">
        <div class="row">
            {% if not domain_settings['user_defined'] %}
            <div class="col s12 m2"></div>
            {% endif %}
            <div class="col s12 m8">
                <div class="card-panel">
                    <h4 class="red-text light-3">System Default</h4>
                    <form action="/advanced/domain" method="post">
                        <input type="hidden" name="tab" value="1">
                        <input type="hidden" name="df_cat_update">
                        <div class="row">
                            {% for category, settings in domain_settings['default'].items() %}
                            <div class="input-field col s4 m4 center">
                                {{category}}
                                <div class="switch">
                                    <label>
                                        Off
                                        {% if category in ['malicious', 'cryptominer'] %}
                                        <input disabled type="checkbox" checked="checked" name="category">
                                        {% else %}
                                        <input type="checkbox" {% if settings['enabled'] %} checked="checked"
                                            {% endif %} name="category" value="{{category}}" onchange="this.form.submit()">
                                        {% endif %}
                                        <span class="lever"></span>
                                        On
                                    </label>
                                </div>
                            </div>
                            {% endfor %}
                        </div>
                        <noscript>
                            <div class="row">
                                <div class="col s12 center">
                                    <button class="btn waves-effect waves-light">
                                        <i class="material-icons"></i> Update
                                    </button>
                                </div>
                            </div>
                        </noscript>
                    </form>
                </div>
            </div>
            {% if domain_settings['user_defined'] %}
            <div class="col s12 m4">
                <div class="card-panel">
                    <h4 class="red-text light-3">User Defined</h4>
                    <form action="/advanced/domain" method="post">
                        <input type="hidden" name="tab" value="1">
                        <input type="hidden" name="ud_cat_update">
                        <div class="row">
                            {% for category, settings in domain_settings['user_defined'].items() %}
                            <div class="input-field col s4 m4 center">
                                {{category}}
                                <div class="switch">
                                    <label>
                                        Off
                                        <input type="checkbox" {% if settings['enabled'] %} checked="checked"
                                            {% endif %} name="ud_category" value="{{category}}" onchange="this.form.submit()">
                                        <span class="lever"></span>
                                        On
                                    </label>
                                </div>
                            </div>
                            {% endfor %}
                        </div>
                        <noscript>
                            <div class="row center">
                                <div class="col s12 m12 center">
                                    <button class="btn waves-effect waves-light">
                                        <i class="material-icons"></i> Update
                                    </button>
                                </div>
                            </div>
                        </noscript>
                    </form>
                </div>
            </div>
            {% endif %}
        </div>
    </div>
</section>
<section id="tlds" class="section">
    <div class="container">
        <div class="row">
            <div class="col s2 m2"></div>
            <div class="col s8 m8">
                <div class="card-panel">
                    <h4 class="red-text light-3">Top Level Domains</h4>
                    <div class="row">
                        <form action="/advanced/domain" method="post">
                            <input type="hidden" name="tab" value="2">
                            <input type="hidden" name="df_tld_update" value="">
                            {% for tld, status in domain_settings['tlds'].items() %}
                            <div class="col s3 m3 center">
                                <div class="row">
                                    <div class="input-field col s12">
                                        {{tld}}
                                        <div class="switch">
                                            <label>
                                                Off
                                                <input type="checkbox" {% if status %} checked="checked" {% endif %}
                                                    name="tld" value="{{tld}}" onchange="this.form.submit()">
                                                <span class="lever"></span>
                                                On
                                            </label>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            {% endfor %}
                            <noscript>
                                <div class="row">
                                    <div class="col s12 center">
                                        <button class="btn waves-effect waves-light">
                                            <i class="material-icons"></i> Update
                                        </button>
                                    </div>
                                </div>
                            </noscript>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>
<section id="keywords" class="section">
    <div class="container">
        <div class="row">
            <div class="col s2 m2"></div>
            <div class="col s8 m8">
                <div class="card-panel">
                    <h4 class="red-text light-3">Keyword Search</h4>
                    <form action="/advanced/domain" method="post">
                        <input type="hidden" name="tab" value="3">
                        <input type="hidden" name="keyword_update" value="">
                        <div class="row">
                            {% for category, settings in domain_settings['default'].items() %}
                            {% if settings['enabled'] %}
                            <div class="input-field col s3 m3 center">
                                {{category}}
                                <div class="switch">
                                    <label>
                                        Off
                                        <input type="checkbox" {% if settings['keyword'] %} checked="checked"
                                            {% endif %} name="keyword" value={{category}} onchange="this.form.submit()">
                                        <span class="lever"></span>
                                        On
                                    </label>
                                </div>
                            </div>
                            {% endif %}
                            {% endfor %}
                        </div>
                        <noscript>
                            <div class="row">
                                <button class="btn waves-effect waves-light">
                                    <i class="material-icons"></i> Update
                                </button>
                            </div>
                        </noscript>
                    </form>
                </div>
            </div>
        </div>
</section>
{% endblock %}